import http from '@/utils/request'
import {useUserStore} from '@/stores/user'

//获取课程分页数据
export const coursePage = (pageQueryParams: any) => {
  return http.request({
    url: '/api/v1/front/course/page',
    method: 'get',
    params: pageQueryParams,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

//获取课程预约分页数据
export const courseReservePage = (pageQueryParams: any) => {
  return http.request({
    url: '/api/v1/front/profile/myCourseReserve',
    method: 'get',
    params: pageQueryParams,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

/**
 * 课程详情
 * @param params
 */
export const courseDetail = (params: any) => {
  return http.request({
    url: '/api/v1/front/course/getCourseForm',
    method: 'get',
    params: params,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

/**
 * 课程计划
 * @param params
 */
export const coursePlans = (params: any) => {
  return http.request({
    url: '/api/v1/front/course-plan/getPlansByCourseId',
    method: 'get',
    params: params,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

/**
 * 课程评论列表
 * @param params
 */
export const courseCommentsPage = (params: any) => {
  return http.request({
    url: '/api/v1/front/course-comment/page',
    method: 'get',
    params: params,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

/**
 * 课程添加评论
 * @param data
 */
export const addCourseComment = (data: any) => {
  return http.request({
    url: '/api/v1/front/course-comment/add',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

/**
 * 预约课程
 * @param data
 */
export const reserveCourse = (data: any) => {
  return http.request({
    url: '/api/v1/front/courseReserve/reserveCourse',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

/**
 * 我的课程安排
 * @param data
 */
export const getMyCourseSchedules = (data: any) => {
  return http.request({
    url: '/api/v1/front/profile/myCourseSchedules',
    method: 'get',
    params: data,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

export const myCourseSchedule = (data: any) => {
  return http.request({
    url: '/api/v1/front/profile/myCourseSchedule',
    method: 'get',
    params: data,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

/**
 * 获取首页分类
 */
export const indexCategory = () => {
  return http.request({
    url: '/api/v1/front/index/category',
    method: 'get',
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

export const addCourseRate = (data:any)=>{
  return http.request({
    url: '/api/v1/front/course-rate/add',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}
export const getCourseRate = (uid: number, cid: number) => {
  return http.request({
    url: '/api/v1/front/course-rate/get',
    method: 'get',
    params: {userId: uid, courseId: cid},
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

export const getRecommendCourses = (uid: number, cid: number) => {
  return http.request({
    url: '/api/v1/front/course/getRecommendCourse',
    method: 'get',
    params: {userId: uid, courseId: cid},
    headers: {
      'Content-Type': 'application/json'
    }
  })
}